import Vue from "vue"
// Make sure to pick a unique name for the flag
// so it won't conflict with any other mixin.
if (!Vue.__my_site_mixin__) {
	Vue.__my_site_mixin__ = true
	Vue.mixin({
		async asyncData({
			$axios,
			store,
			route,
			query,
			req,
			res,
			redirect
		}) {
			//只有路由跳转 才会走这里
			console.log(`站点混淆site-mixin.js 监听页面跳转路由:${route.path}`)
			// let data = await getSite($axios, {
			// 	path: route.path
			// }).catch(err => {
			// 	return {}
			// });
			let data = { result: { seoTitle: 'IP365X', seoKeywords: 'IP365X', seoDescription: 'IP365X' } }
			let preTitle = '';
			let preKeywords = '';
			let preDescription = '';
			console.log(route.path, 'path')
			if (route.path.toLowerCase() == '/sitemap') {
				preTitle = '站点地图_';
				preKeywords = '站点地图_';
				preDescription = '站点地图_';
			} else if (route.path == '/search') {
				preTitle = '搜索_';
				preKeywords = '搜索_';
				preDescription = '搜索_';
			} else if (route.path == '/need') {
				preTitle = '被授权商需求列表_';
				preKeywords = '被授权商需求列表_';
				preDescription = '被授权商需求列表_';
			}

			let seoData = data.result ? {
				title: preTitle + data.result.seoTitle,
				keywords: preKeywords + data.result.seoKeywords,
				description: preDescription + data.result.seoDescription
			} : {};
			store.commit("setSeo", seoData);
			return {};
		},
		
	}) // Set up your mixin then
}
